﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace project2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入数组的大小");
            int N = int.Parse(Console.ReadLine());
            double[] array = new double[N];
            for(int i = 0; i < N; i++)
            {
                array[i] = i + 1;//为数组赋值 用于测试
            }
            arrayfun testclass = new arrayfun();
            double max = testclass.max(array);
            Console.WriteLine("数组的最大值为：{0}", max);
            double min = testclass.min(array);
            Console.WriteLine("数组的最小值为：{0}", min);
            double average = testclass.pingjun(array);
            Console.WriteLine("数组的平均值为：{0}", average);
            double sum = testclass.sum(array);
            Console.WriteLine("数组最大值为：{0}", sum);
            Console.ReadKey();
        }
    }

    class arrayfun
    {
        public double max(double[] array)
        {
            double result = array[0];
            for(int i = 0; i < array.Length; i++)
            {
                if (array[i] > result)
                {
                    result = array[i];
                }
            }
            return result;
        }

        public double min(double[] array)
        {
            double result = array[0];
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i] < result)
                {
                    result = array[i];
                }
            }
            return result;
        }

        public double pingjun(double[] array)
        {
            double result = 0;
            for(int i = 0; i < array.Length; i++)
            {
                result = result + array[i];
            }
            result = result / array.Length;
            return result;
        }

        public double sum(double[] array)
        {
            double result = 0;
            for (int i = 0; i < array.Length; i++)
            {
                result = result + array[i];
            }
            return result;
        }
    }
}
